home *** CD-ROM | disk | FTP | other *** search
-
- CryptaPix (tm) 2.0
- Protocols and File Format
- (Revised 8/27/98)
-
-
- Program Description
- -------------------
-
- CryptaPix is a 32-bit graphic image viewer for Windows based personal
- computers. CryptaPix features a symmetric encryption option that allows
- the user to encrypt industry standard BMP, GIF, JPG, PCX, PNG, and TIF
- images. The ciphertext output file is in a proprietary format with an
- extension of CPX. It contains a full sized image, a thumbnail representation
- of the image in BMP format, an optional a WAV format sound clip, and the
- original filename. All four sections are encrypted with either the PC1
- or Blowfish algorithms.
-
-
- Blowfish Algorithm
- ------------------
-
- Blowfish is a fast, unpatented variable size-key block encryption
- algorithm invented by Bruce Schneier, security consultant and author of
- "Applied Cryptography" (Wiley, ISBN 0-471-11709-9).
-
- The Blowfish algorithm used in CryptaPix follows the original specification
- as described in the April 1994 edition of Dr. Dobb's Journal and the
- second edition of "Applied Cryptography".
-
- CryptaPix runs Blowfish with a 160-bit key in Cipher Block Chaining (CBC)
- mode. An 8-byte initialization vector (IV) is generated from the
- compiler's (Borland Delphi) pseudo random number generator (PRNG). The
- PRNG is seeded with data from the system clock at startup to ensure a
- unique IV for each file.
-
-
- PC1 Algorithm
- -------------
-
- PC1 is a very fast, unpatented variable size-key stream cipher that
- produces an identical key stream as RSA Data Security Inc's RC4
- algorithm. The algorithm follows the RC4 specification as described by
- Schneier in "Applied Cryptography".
-
- CryptaPix runs PC1 with a key consisting of 40 or 80 bits of secret key
- material and 40 bits of salt provided by the compiler's PRNG.
-
-
- Export Restrictions
- -------------------
-
- Due to U.S. export restrictions on encryption technology, the 80-bit PC1
- and 160-bit Blowfish algorithms are only available to registered users
- who reside in the U.S. or Canada.
-
-
- Key Generation
- --------------
-
- Encryption keys are generated from the user's password. Passwords can be
- up to 50 characters in length using any character available from the
- keyboard. The user has the option of setting a "case sensitivity" flag at
- run-time which is saved in the header of the ciphertext file. If this flag
- is disabled, the password is converted to uppercase.
-
- Five bytes of random salt from the compiler's PRNG are appended to the
- password and then run through the Secure Hash Algorithm (SHA-1) to produce a
- 160-bit hash value. The lower 40 or 80 bits from the hash output are used
- as the secret portion of the encryption key when the PC1 algorithm is used.
- All 160 bits are used with the Blowfish algorithm. The SHA-1 algorithm
- conforms to FIPS PUB 180-1 specification as published by the National
- Institute of Standards and Technology (NIST). The password salt is saved
- in the header of the ciphertext file.
-
-
- Key Confirmation
- ----------------
-
- CryptaPix has a key confirmation feature that will determine if the user
- enters an incorrect password during decryption. A 64-bit IV is filled
- with output from the compiler's PRNG.
-
- For the PC1 algorithm, the first 40 bits of the IV are used as salt for
- the key. The other 24 bits of the IV are not used. The 40 or 80-bit
- encryption key is appended to the salt resulting in an 80 or 120-bit key.
- The PC1 engine is then cycled 10,000 times with results discarded. Two more
- cycles are made and the 16-bit result is saved in the password check variable.
- When the Blowfish algorithm is used, the 64-bit IV is encrypted with the
- key and the lower 16 bits of the resulting ciphertext is saved in the
- password check variable.
-
- Both the IV and the password check variable are saved in the ciphertext
- file's header. During decryption, the IV is retrieved from the header and
- the process is repeated. If the password check matches the stored value
- then the password is assumed to be correct and the decryption process
- continues.
-
- The global IV/salt is only used for the password check. Each encrypted
- section in the output file uses a unique IV/salt.
-
-
- CPX File Format
- ---------------
-
- The default file extension for an encrypted CryptaPix file is ".CPX".
- CPX files begin with a file header, shown here in 32-bit Delphi format:
-
- fheader = packed record
- id: array[1..4] of char;
- version: byte;
- encryption: byte;
- pwcase: boolean;
- pwsalt: array[1..5] of byte;
- pwiv: array[1..8] of byte;
- pwcheck: word;
- ioffset: integer;
- tnoffset: integer;
- woffset: integer;
- fnoffset: integer;
- end;
-
- The id field is always 'CPIX'.
- The version field is 20 which represents version 2.0.
- The three possible values for the encryption field are:
- 1: 40-bit PC1
- 2: 80-bit PC1 (not available in exportable version)
- 3: 160-bit Blowfish (not available in exportable version)
- The pwcase field is true (1) if the user set the password case sensitivity
- flag, otherwise it is false (0).
- The pwsalt field is 5 bytes of random salt from the compiler's PRNG. These
- bytes are appended to the user's password before hashing with SHA-1.
- The pwiv field is 8 random bytes form the compiler's PRNG. When encryption
- method 3 is used, all 8 bytes are used as an initialization vector for the
- password confirmation feature. When encryption methods 1 and 2 are used,
- the first 5 bytes are used as a key salt.
- The pwcheck field is used for password confirmation as described earlier.
- The ioffset field contains the file offset for the encrypted image header.
- The tnoffset field contains the file offset for the encrypted thumbnail
- header.
- The woffset field contains the file offset for the encrypted WAV sound clip
- header.
- The fnoffset field contains the file offset for the encrypted file name.
-
-
- Image Header
- ------------
-
- The offset of the image header is specified by the ioffset field in the
- main file header. The format for the image header is shown here in Pascal
- format:
-
- iheader = packed record
- id: array[1..6] of char;
- ext: string[3];
- size: integer;
- iv: array[1..8] of byte;
- end;
-
-
- The id field is always 'CPIX00';
- The ext field is set to the source image's file extension: 'BMP', 'GIF',
- 'JPG', 'PCX', 'PNG', or 'TIF'.
- The size field is the original image's file size in bytes.
- The iv field is 8 random bytes from the compiler's PRNG. When encryption
- method 3 is used, all 8 bytes are used as an initialization vector. When
- encryption methods 1 and 2 are used, the first 5 bytes are used as a key
- salt.
-
- The encrypted image immediately follows the image header. Random bytes are
- appended to the plaintext if necessary to make the output size a multiple
- of 8 bytes.
-
-
- Thumbnail Header
- ----------------
-
- A thumbnail is a small (120 x 90 pixel) representation of the main image.
- CryptaPix creates it during the encryption process and saves it in a
- standard JPEG format.
-
- The offset of the thumbnail header is specified by the tnoffset field in
- the main file header. The format for the thumbnail header is shown here
- in Pascal format:
-
- tnheader = packed record
- id: array[1..6] of char;
- size: integer;
- iv: array[1..8] of byte;
- end;
-
- The id field is always 'CPIX01';
- The size field is the original thumbnail's file size in bytes.
- The iv field is 8 random bytes from the compiler's PRNG. When encryption
- method 3 is used, all 8 bytes are used as an initialization vector. When
- encryption methods 1 and 2 are used, the first 5 bytes are used as a key
- salt.
-
- The encrypted thumbnail immediately follows the thumbnail header. Random
- bytes are appended to the plaintext if necessary to make the output size a
- multiple of 8 bytes.
-
-
- WAV Header
- ----------
-
- A WAV file is a sound clip in the industry standard WAV format.
-
- The offset of the WAV header is specified by the woffset field in the main
- file header. The format for the WAV header is shown here in Pascal format:
-
- wheader = packed record
- id: array[1..6] of char;
- size: integer;
- iv: array[1..8] of byte;
- end;
-
-
- The id field is always 'CPIX02';
- The size field is the original WAV file size in bytes. The size is set to
- 0 if no sound clip was saved with the file.
- The iv field is 8 random bytes from the compiler's PRNG. When encryption
- method 3 is used, all 8 bytes are used as an initialization vector. When
- encryption methods 1 and 2 are used, the first 5 bytes are used as a key
- salt.
-
- The encrypted WAV sound immediately follows the WAV header. Random bytes
- are appended to the plaintext if necessary to make the output size a
- multiple of 8 bytes.
-
-
- Filename Header
- ---------------
-
- The original filename is stored in the CPX in an encrypted format.
-
- The offset of the filename header is specified by the fnoffset field in the main
- file header. The format for the filename header is shown here in Pascal format:
-
- fnheader = packed record
- id: array[1..6] of char;
- size: integer;
- iv: array[1..8] of byte;
- end;
-
-
- The id field is always 'CPIX03';
- The size field is the length of the filename in bytes.
- The iv field is 8 random bytes from the compiler's PRNG. When encryption
- method 3 is used, all 8 bytes are used as an initialization vector. When
- encryption methods 1 and 2 are used, the first 5 bytes are used as a key
- salt.
-
- The encrypted filename immediately follows the filename header as an array
- of characters. Random bytes are appended to the plaintext if necessary to
- make the output size a multiple of 8 bytes.
-
- Thumbnail Database Format
- -------------------------
-
- CryptaPix stores thumbnails for non-encrypted images in central database
- files located in a directory specified by the user in the Options/Preferences
- section of the program. A separate .tdb file is maintained for each disk
- volume using the disk's 8-digit hex serial number for the file name. A
- corresponding index file with an .ndx extension contains sorted pointers for
- the .tdb file.
-
- The .tdb file begins with this header:
-
- tdbrec: packed record
- id: array[1..7] of char;
- ver: byte;
- volume: string[255];
- num: integer;
- end;
-
- The id field is 'CPIXTDB'.
- The ver field is 20, representing version 2.0.
- The volume field is the disk's volume label.
- The num field is the number of thumbnail records in the database.
-
- Following the tdbrec header are the individual thumbnails, stored in a
- standard JPG format not exceeding 120 pixels in width or 90 pixels in
- height. Just before each thumbnail is a thumbnail header:
-
- tnrec: packed record
- nextrec: integer;
- name: string[255];
- size: integer;
- end;
-
- The nextrec field contains the file offset of the next thumbnail header.
- The name field contains the full path name of the full size image file.
- The size field contains the number of bytes in the thumbnail.
-
- A deleted thumbnail will have a blank file name and its data area filled
- with zeros. Deleted and orphaned thumbnails can be physically removed
- from the database file with the thumbnail database maintenance functions.
-
- The index file contains a list of 32-bit pointers (sorted by file name)
- that are offsets to the tnrec headers in the .tdb file.
-
- ndxrec: packed record
- id: array[1..7] of char;
- ver: byte;
- end;
-
- The id field is set to 'CPIXNDX'.
- The ver field is set to 20, representing version 2.0.
-
- ---End of File---
-